﻿var app = app || {};
app.schoolApp = angular.module('schoolApp', ['app.service', 'ngRoute', 'app.Controllers', 'ngplus', 'ngAnimate']);
app.schoolApp.config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
    $routeProvider.
        when("/Students", { templateUrl: "Student/Students", controller: "student" }).
        when("/Student/:id", { templateUrl: "Student/Student", controller: "student" }).
        otherwise({ redirectTo: '/Students' });
    
    //$httpProvider.interceptors.push(function ($q, $rootScope) {
    //    return {
    //        'request': function (config) {
    //            $rootScope.$broadcast('loading-started');
    //            return config || $q.when(config);
    //        },
    //        'response': function (response) {
    //            $rootScope.$broadcast('loading-complete');
    //            return response || $q.when(response);
    //        }
    //    };
    //});
}
]);


//app.schoolApp.config(function ($httpProvider) {

//    $httpProvider.interceptors.push(function ($q, $rootScope) {
//        return {
//            'request': function (config) {
//                $rootScope.$broadcast('loading-started');
//                return config || $q.when(config);
//            },
//            'response': function (response) {
//                $rootScope.$broadcast('loading-complete');
//                return response || $q.when(response);
//            }
//        };
//    });

//});


//app.schoolApp.directive("loadingIndicator", function () {
//    return {
//        restrict: "A",
//        template: "<div>Loading...</div>",
//        link: function (scope, element, attrs) {
//            scope.$on("loading-started", function (e) {
//                element.css({ "display": "" });
//            });

//            scope.$on("loading-complete", function (e) {
//                element.css({ "display": "none" });
//            });

//        }
//    };
//});
